#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
void inputString(const char * prompt, char * input)
{
	input[0] = 0;
	printf("%s", prompt);
	scanf("%[^\n]", input);
	fflush(stdin);
}
int brackets_balance(char * string)
{
	const char * brackets="()";
	int i, n=0;
	for(i=0; i<strlen(string); i++)
	{
		if(string[i]==brackets[0]) n++;
		if(string[i]==brackets[1]) n--;
		if(n<0) return 0;
	}
	return (n==0);
}
void main()
{
	char string[1000]="";
	inputString("Input string: ", string);
	printf("Brackets balanced? (1 - Yes, 0 - Nope): %d\n", brackets_balance(string));
	system("PAUSE");
}
		
